home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MSG Graphic Effects 1.0 Source / Mr. Do outdone.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-23  |  3.5 KB  |  167 lines  |  [TEXT/KAHL]

  1. /*******************************************************************************
  2.  * Copyright © 1992-1993 Mark Pilgrim                                          *
  3.  *                                                                             *
  4.  * This file is provided as is, and may be freely distributed unaltered.  This *
  5.  * message must accompany any copy of this file.  This file may be used or     *
  6.  * modified for use for a non-commercial product provided that appropriate     *
  7.  * credit is given to the author named above.                                  *
  8.  * Commercial use of this source code is prohibited.                           *
  9.  ******************************************************************************/
  10.  
  11. #include "msg misc.h"
  12. #include "msg timing.h"
  13.  
  14. #define        BoxSize    2
  15. #define CorrectTime 3
  16.  
  17. void MrDoOutdone(GrafPtr);
  18.  
  19. /* 25 regions on screen, in a 5 x 5 grid.  Regions alternate as to whether they
  20.    scroll up or down. */
  21.    
  22. void MrDoOutdone(GrafPtr sourceGrafPtr)
  23. {
  24.     int            x, y;
  25.     int            vgap,hgap;
  26.     Rect        theRect, dest;
  27.     Rect        scrollsource, scrolldest;
  28.     Rect        bounds[25];
  29.     
  30.     vgap=MAIN_WINDOW_HEIGHT/5;
  31.     hgap=MAIN_WINDOW_WIDTH/5;
  32.     
  33.     for (x=0; x<25; x++)
  34.     {
  35.         switch (x)
  36.         {
  37.             case 0:
  38.             case 1:
  39.             case 2:
  40.             case 3:
  41.             case 4:
  42.                 bounds[x].top=0;
  43.                 break;
  44.             case 15:
  45.             case 16:
  46.             case 17:
  47.             case 18:
  48.             case 5:
  49.                 bounds[x].top=vgap;
  50.                 break;
  51.             case 14:
  52.             case 23:
  53.             case 24:
  54.             case 19:
  55.             case 6:
  56.                 bounds[x].top=vgap*2;
  57.                 break;
  58.             case 13:
  59.             case 22:
  60.             case 21:
  61.             case 20:
  62.             case 7:
  63.                 bounds[x].top=vgap*3;
  64.                 break;
  65.             case 12:
  66.             case 11:
  67.             case 10:
  68.             case 9:
  69.             case 8:
  70.                 bounds[x].top=vgap*4;
  71.                 break;
  72.         }
  73.         switch (x)
  74.         {
  75.             case 0:
  76.             case 15:
  77.             case 14:
  78.             case 13:
  79.             case 12:
  80.                 bounds[x].left=0;
  81.                 break;
  82.             case 1:
  83.             case 16:
  84.             case 23:
  85.             case 22:
  86.             case 11:
  87.                 bounds[x].left=hgap;
  88.                 break;
  89.             case 2:
  90.             case 17:
  91.             case 24:
  92.             case 21:
  93.             case 10:
  94.                 bounds[x].left=hgap*2;
  95.                 break;
  96.             case 3:
  97.             case 18:
  98.             case 19:
  99.             case 20:
  100.             case 9:
  101.                 bounds[x].left=hgap*3;
  102.                 break;
  103.             case 4:
  104.             case 5:
  105.             case 6:
  106.             case 7:
  107.             case 8:
  108.                 bounds[x].left=hgap*4;
  109.                 break;
  110.         }
  111.         bounds[x].bottom=bounds[x].top+vgap;
  112.         bounds[x].right=bounds[x].left+hgap;
  113.     }
  114.     
  115.     for (x=BoxSize; x<vgap; x+=BoxSize)
  116.     {        
  117.         StartTiming();
  118.         for (y=0; y<25; y++)
  119.         {
  120.             if (y%2)   /* these scroll up */
  121.             {
  122.                 scrollsource=bounds[y];
  123.                 scrollsource.top+=BoxSize;
  124.                 scrolldest=scrollsource;
  125.                 OffsetRect(&scrolldest,0,-BoxSize);
  126.                 
  127.                 dest=bounds[y];
  128.                 dest.top=dest.bottom-BoxSize;
  129.                 
  130.                 theRect=bounds[y];
  131.                 theRect.top+=x-BoxSize;
  132.                 theRect.bottom=theRect.top+BoxSize;
  133.             
  134.                 CopyBits(&(gMainWindow->portBits), &(gMainWindow->portBits),
  135.                         &scrollsource, &scrolldest, 0, 0L);
  136.                 CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  137.                         &theRect, &dest, 0, 0L);
  138.             }
  139.             else    /* these scroll down */
  140.             {
  141.                 scrollsource=bounds[y];
  142.                 scrollsource.bottom-=BoxSize;
  143.                 scrolldest = scrollsource;
  144.                 OffsetRect(&scrolldest, 0, BoxSize);
  145.                 
  146.                 dest=bounds[y];
  147.                 dest.bottom=dest.top+BoxSize;
  148.                 
  149.                 theRect=bounds[y];
  150.                 theRect.bottom-=x-BoxSize;
  151.                 theRect.top=theRect.bottom-BoxSize;
  152.                 
  153.                 CopyBits(&(gMainWindow->portBits), &(gMainWindow->portBits),
  154.                         &scrollsource, &scrolldest, 0, 0L);
  155.                 CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  156.                         &theRect, &dest, 0, 0L);
  157.             }
  158.         }
  159.         TimeCorrection(CorrectTime);
  160.     }
  161.     for (y=0; y<25; y++)
  162.     {
  163.         CopyBits(&(sourceGrafPtr->portBits),&(gMainWindow->portBits),
  164.                     &bounds[y],&bounds[y],0,0L);    /* fill in any missing bits */
  165.     }
  166. }
  167.